package com.entity;

import java.io.Serializable;
import javax.persistence.*;

import com.alibaba.fastjson.annotation.JSONField;

import java.math.BigDecimal;
import java.util.Date;
import java.util.List;


/**
 * The persistent class for the ODO database table.
 * 
 */
@Entity
@NamedQuery(name="Odo.findAll", query="SELECT o FROM Odo o")
public class Odo implements Serializable {
	private static final long serialVersionUID = 1L;

	@Id
	@SequenceGenerator(name="ODO_ODOID_GENERATOR", sequenceName="SEQ",initialValue=1,allocationSize=1)
	@GeneratedValue(strategy=GenerationType.SEQUENCE, generator="ODO_ODOID_GENERATOR")
	@Column(name="ODO_ID")
	private long odoId;

	@Column(name="ODO_CHARGE")
	private String odoCharge;

	@Temporal(TemporalType.DATE)
	@JSONField(format="yyyy-MM-dd")
	@Column(name="ODO_DATE")
	private Date odoDate;

	@Column(name="ODO_REMARK")
	private String odoRemark;

	@Column(name="ODO_STATE")
	private BigDecimal odoState;

	//bi-directional many-to-one association to Invoice
	@OneToMany(cascade={CascadeType.ALL},mappedBy="odo")
	
	private List<Invoice> invoices;

	//bi-directional many-to-one association to Order
	@ManyToOne
	@JoinColumn(name="OR_ID")
	private Order order;
	
	@ManyToMany
	@JoinTable(name="ODO_DELIVER",joinColumns=@JoinColumn(name="ODO_ID"),inverseJoinColumns=@JoinColumn(name="DELIVER_ID"))
	private List<Deliver> delivers;

	
	
	public List<Deliver> getDelivers() {
		return delivers;
	}

	public void setDelivers(List<Deliver> delivers) {
		this.delivers = delivers;
	}
	
	@Transient
	private String state;
	

	public String getState() {
		return state;
	}

	public void setState(String state) {
		this.state = state;
	}

	public Odo() {
	}

	public long getOdoId() {
		return this.odoId;
	}

	public void setOdoId(long odoId) {
		this.odoId = odoId;
	}

	public String getOdoCharge() {
		return this.odoCharge;
	}

	public void setOdoCharge(String odoCharge) {
		this.odoCharge = odoCharge;
	}

	public Date getOdoDate() {
		return this.odoDate;
	}

	public void setOdoDate(Date odoDate) {
		this.odoDate = odoDate;
	}

	public String getOdoRemark() {
		return this.odoRemark;
	}

	public void setOdoRemark(String odoRemark) {
		this.odoRemark = odoRemark;
	}

	public BigDecimal getOdoState() {
		return this.odoState;
	}

	public void setOdoState(BigDecimal odoState) {
		this.odoState = odoState;
	}

	public List<Invoice> getInvoices() {
		return this.invoices;
	}

	public void setInvoices(List<Invoice> invoices) {
		this.invoices = invoices;
	}

	public Invoice addInvoice(Invoice invoice) {
		getInvoices().add(invoice);
		invoice.setOdo(this);

		return invoice;
	}

	public Invoice removeInvoice(Invoice invoice) {
		getInvoices().remove(invoice);
		invoice.setOdo(null);

		return invoice;
	}

	public Order getOrder() {
		return this.order;
	}

	public void setOrder(Order order) {
		this.order = order;
	}

	@Override
	public String toString() {
		return "Odo [odoId=" + odoId + ", odoCharge=" + odoCharge + ", odoDate=" + odoDate + ", odoRemark=" + odoRemark
				+ ", odoState=" + odoState + ", invoices=" + invoices + ", order=" + order + ", delivers=" + delivers
				+ "]";
	}
	
	

}